package com.softqin.washer.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;

import com.softqin.washer.R;
import com.softqin.washer.activity.HomeBusinessActivity;
import com.softqin.washer.activity.HomePromotionActivity;
import com.softqin.washer.activity.HomeServeActivity;
import com.softqin.washer.activity.HomeSurroundActivity;
import com.softqin.washer.common.WasherApp;
import com.softqin.washer.utils.DialogUtils;

/**
 * 
 * @ClassName: HomeFragment
 * 
 * @Description: TODO(��ʾ��ҳ����)
 * 
 * @author ��ʢΰ
 * 
 * @date 2014-12-27 ����10:53:00
 */
public class HomeFragment extends Fragment implements OnClickListener {
	private final static String TAG = "HomeFragment";
	private View mView_home;
	// �ж��Ƿ��Ѿ��������
	private boolean mIsLoad;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		mView_home = inflater.inflate(R.layout.fragment_home, container);
		initView(mView_home);
		Log.i("sysout", "Home");
		return mView_home;
	}

	private void initView(View v) {
		v.findViewById(R.id.home_business).setOnClickListener(this);
		v.findViewById(R.id.home_serve).setOnClickListener(this);
		v.findViewById(R.id.home_promotion).setOnClickListener(this);
		v.findViewById(R.id.home_surround).setOnClickListener(this);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
	}

	@Override
	public void onHiddenChanged(boolean hidden) {
		// TODO Auto-generated method stub
		super.onHiddenChanged(hidden);
		if (hidden && WasherApp.getInstance().mIHomepageBottomId != 1) {// ���ص�ǰFragment
			Log.i(TAG, "HomeFragment->this.isVisible()��");
			mIsLoad = false;
		} else if (!mIsLoad) {
			// ��ʾ��ǰFragment,�����������
			Log.i(TAG, "��ʾ��ǰHomeFragment,�����������");
			// ������
			mIsLoad = true;// �ڴ��ڲ�����ʵ��
		}
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.home_business:// �̼�
			startActivity(new Intent(HomeFragment.this.getActivity(),
					HomeBusinessActivity.class));
			break;
		case R.id.home_serve:// ����
			startActivity(new Intent(HomeFragment.this.getActivity(),
					HomeServeActivity.class));
			break;
		case R.id.home_promotion:// �
			startActivity(new Intent(HomeFragment.this.getActivity(),
					HomePromotionActivity.class));
			break;
		case R.id.home_surround:// �ܱ�
			startActivity(new Intent(HomeFragment.this.getActivity(),
					HomeSurroundActivity.class));
			break;

		default:
			break;
		}
	}

}
